package com.pzb.web.controller.goods;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pzb.common.annotation.Log;
import com.pzb.common.core.controller.BaseController;
import com.pzb.common.core.domain.AjaxResult;
import com.pzb.common.enums.BusinessType;
import com.pzb.goods.domain.GdGoodsAttributeOption;
import com.pzb.goods.service.IGdGoodsAttributeOptionService;
import com.pzb.common.core.page.TableDataInfo;

/**
 * 属性选项Controller
 * 
 * @author Mr_Wu
 * @date 2021-11-29
 */
@RestController
@RequestMapping("/goods/option")
public class GdGoodsAttributeOptionController extends BaseController
{
    @Autowired
    private IGdGoodsAttributeOptionService gdGoodsAttributeOptionService;

    /**
     * 查询属性选项列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GdGoodsAttributeOption gdGoodsAttributeOption)
    {
        startPage();
        List<GdGoodsAttributeOption> list = gdGoodsAttributeOptionService.selectGdGoodsAttributeOptionList(gdGoodsAttributeOption);
        return getDataTable(list);
    }


    /**
     * 获取属性选项详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gdGoodsAttributeOptionService.selectGdGoodsAttributeOptionById(id));
    }

    /**
     * 新增属性选项
     */
    @Log(title = "属性选项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GdGoodsAttributeOption gdGoodsAttributeOption)
    {
        return toAjax(gdGoodsAttributeOptionService.insertGdGoodsAttributeOption(gdGoodsAttributeOption));
    }

    /**
     * 修改属性选项
     */
    @Log(title = "属性选项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GdGoodsAttributeOption gdGoodsAttributeOption)
    {
        return toAjax(gdGoodsAttributeOptionService.updateGdGoodsAttributeOption(gdGoodsAttributeOption));
    }

    /**
     * 删除属性选项
     */
    @Log(title = "属性选项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gdGoodsAttributeOptionService.deleteGdGoodsAttributeOptionByIds(ids));
    }
}
